#ifndef _NET_IO
#define _NET_IO

#include <time.h>

#include <list>
#include <string>
using std::list;
using std::string;

#include "config.h"
#include "common/common.h"
#include "share/Share.h"

namespace NetIO
{
class OperationType
{
private:
	OperationType ( );
	~OperationType( );
	OperationType( const OperationType &optype );
	OperationType & operator = ( const OperationType &optype );
public:
	enum
	{
		NONE = -1,
		READ,
		WRITE,
		CONNECT,
		ACCEPT,
		MAX
	};

};
}

#ifdef THREAD_SAFE
typedef Thread_Mutex	Synch_Mutex;
#else
typedef Null_Mutex		Synch_Mutex;
#endif

#define TRACE_FUNC TRACE_LOG(__FUNCTION__)

#include "Reactor_Interrupter.h"
#include "Reactor.h"
#include "Event_Handler.h"
#include "Operation.h"
#include "Operation_Result.h"
#include "Handle_Set.h"
#include "Completed_Queue.h"
#include "ObjectCache.h"
#include "Reactor_Impl.h"
#include "Epoll_Reactor.h"
#include "Select_Reactor.h"
#include "Acceptor.h"
#include "Signal.h"
#include "SockOps.h"


namespace NetIO
{
DllExport int
async_read( Socket handle, DataBlock *data_block, void *act = 0, Reactor *reactor = Singleton<Reactor>::instance( ) );

DllExport int
async_write( Socket handle, DataBlock *data_block, void *act = 0, Reactor *reactor = Singleton<Reactor>::instance( ) );

DllExport int
async_accept( Socket listen_handle, void *act = 0, Reactor *reactor = Singleton<Reactor>::instance( ) );

DllExport int
async_connect( const string &ip, short port, void *act = 0, Reactor *reactor = Singleton<Reactor>::instance( ) );

DllExport void
async_cancel( Socket handle, Reactor *reactor = Singleton<Reactor>::instance( ) );

DllExport int
async_operation_result( EventHandle &handle
                        , DataBlock *&data_block
                        , int &bytes_trans
                        , int &errcode
                        , void *&act
                        , Reactor *reactor = Singleton<Reactor>::instance( ) );

DllExport int
async_operation_result( Operation_Result &result
                        , Reactor *reactor = Singleton<Reactor>::instance( ) );
};

using namespace NetIO;

#endif
